<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" oninput="setUser(this)">
    <div id="result"></div>
</body>
<script>
    const data = {};
    let myValue;
    Object.defineProperty(data, 'name', {
        get() {
            return myValue;
        },
        set(value) {
            myValue = value;
            // 进行DOM操作
            document.querySelector('#result').innerHTML = value;
        }
    })

    function setUser(e) {
        // document.querySelector('#result').innerHTML = e.value;
        data.name = e.value;
    }

</script>
</html>